package me.raih.mapper;

import me.raih.pojo.po.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author Raih
 * @Time 2020/11/27  17:05
 */
@Mapper
@Repository
public interface UserMapper {
    /**
     * 查找所有的用户
     * @return  List<User>
     */
    List<User> findAllUsers();

    List<User> findUserByCurrentPageAndPageSize(@Param("currentPage") int currentPage,
                                                @Param("pageSize") int pageSize,
                                                @Param("userName")String userName,
                                                @Param("name")String name,
                                                @Param("email")String email,
                                                @Param("phone") long phone,
                                                @Param("address")String address);

    int findCountByCondition(@Param("userName")String userName,
                             @Param("name")String name,
                             @Param("email")String email,
                             @Param("phone") long phone,
                             @Param("address")String address);

    User findUserByUsername(@Param("username") String username);

    int updateUserByUser(User user);


    int insertUser(User user);

    User findUserByUsernameAndPassword(@Param("username") String username,@Param("password") String password);

    User findUserByUserName(@Param("username") String username);

    User findUserByPhone(@Param("phone")long phone);

    int updatePointByUsername(@Param("username") String username,@Param("points") double points);

    int insertRegisterUser();

    User findUserByUsernameAndCheckCode(@Param("username") String username,@Param("checkCode") String checkCode);

    int changeStatus(@Param("username") String username);

    int findUserNumber();

    int findTodayUserNumber();

    int findYesterdayUserNumber();

    int findCurrMonthUserNumber();

    int findCurrWeekUserNumber();

    /**
     * 查积分
     * @param username 谁查
     * @return 查出来了
     */
    double findPointsByUsername(@Param("username") String username);

    /**
     * 删除用户
     * @param username 用户名
     * @return 1
     */
    int deleteUserByUsername(@Param("username") String username);

}
